//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------
/*
	Description:
				window class for load context
*/

#ifndef _UX_WINAPI_LOAD_WINDOW_H
#define _UX_WINAPI_LOAD_WINDOW_H

#include "WinAPI.h"
#include "../IWindow.h"
#include "../../Core/CCore.h"

#ifdef PLATFORM_WINDOWS

namespace Engine
{
namespace CoreSystems
{

	//
	// Shared Window
	//

	class _EXPORT_ CLoadWindow : public IWindow
	{	
	private:
		CCore		*			_pCore;
		TThread					_sThread;
		operations_queue_t		_aOpQueue;
		TCriticalSection		_sCSLockQueue;
		volatile uint8			_bLooping;
		
	private:
		LRESULT _MsgProc(const TSystemMsg &sMsg);
		bool	_AddSharedWindow(IWindow *pWindow)	{ return false; }
		bool	_Start(e_thread_priority::type ePriority, CCore *pCore);
		uint	_MainLoop();

		static DThreadProc( _s_ThreadProc );

	public:
		CLoadWindow();
		~CLoadWindow();
		
		// IWindow //
		bool Init();
		bool  MainLoop()				{ return true; }
		void  MakeCurrent() const		{ OSAPI()->MakeCurrent( _sHandles ); }
		bool  Show()					{ return OSAPI()->ShowWindow( _sHandles ); }
		bool  Hide()					{ return OSAPI()->HideWindow( _sHandles ); }
		bool  IsPaused()				{ return false; }
		void  AllowPause(bool bAllow)	{}
		bool  Quit();

		CInput * GetInputSystems()		{ return nullptr; }

		void  AddEventListener(IWindowEventListener *pEvList, e_win_event::type eEvents);
		void  RemoveEventListener(IWindowEventListener *pEvList);

		void  AddUpdater(IWindowUpdater *pUpd);
		void  RemoveUpdater(IWindowUpdater *pUpd);
		
		void  ShowFPS(bool bShow);
		bool  SetCaption(const char *pCaption);
		
		bool ChangeWindowParams(const TRenderParams &sRParams);
		
		bool  GetSharedWindow(e_thread::type, IWindow *&)	{ return false; }
		bool  FreeSharedWindow(IWindow *)					{ return false; }
		
		void  SendEvent(const TWindowEvent &sEvent)			{ return; }

		// IThread //
		bool  Push(IOperation *pOp, bool bHighPriority = false);
		void  Exit();
		bool  Pause();
		bool  Resume();
		bool  IsCurrent();

		// CEngBaseObject //
		void  Release();
	};

//-------------------------------------------------------------------

}	// CoreSystems
}	// Engine

#endif	// PLATFORM_WINDOWS

#endif	// _UX_WINAPI_LOAD_WINDOW_H